<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>资讯速递</title>
<meta name="keywords" content="" />
<link type="text/css" rel="stylesheet" media="screen" href="__FONT__/css/style.css{$JSDEBUG}"/>
<link type="text/css" rel="stylesheet" media="screen" href="__FONT__/css/media.css{$JSDEBUG}"/>
<script type="text/javascript" src="__FONT__/js/jquery-1.9.1.min.js"></script>
<script>
function textFormat() {
	$(".contain li p").each(function(){
		var maxwidth=22;
		if($(this).text().length>maxwidth){
			$(this).text($(this).text().substring(0,maxwidth));
			$(this).html($(this).html()+'…');
		}
	});
}
$(document).ready(function(){
	//限制字符个数
	textFormat();
});
</script>
</head>
<body>
	<include file="Public/customHeader" title="资讯速递" url="{:U('User/index')}"/>
	<div class="contain">
		<if condition="$lists">
   		<ul class="biankuang">
	      	<foreach name="lists" item="zixun">
			<li>
	           <a target="_blank" href="{:U('Article/detail/id/'.$zixun['id'])}" >
	           <div class="zi_left">
	               <h1>{$zixun.title}</h1>
	               <p>{$zixun.article_desc}</p>
	               <span>{$zixun.created|date="Y-m-d H:i:s",###}</span>
	           </div>
	           <div class="img">
	           	<img src="__UPLOADS__/Article/medium/{$zixun.img_path}">
	           </div>
	           </a>
			</li>
			</foreach>
	      </ul>
	    <else />
	    <div class="no_bank"><h1>美滴滴</h1><p>没有咨询速递内容~</p></div>
	  	</if>  
    </div>
    <if condition="$hasMore">
    <div class="loadmore">
      <p><a id="loadMore" href="{$nextPageUrl}">加载更多</p>
    </div>
    </if>
</body>
<if condition="$hasMore">
<script>
// 功能:停止事件冒泡  
function stopBubble(e) {

    // 如果提供了事件对象，则这是一个非IE浏览器

    if ( e && e.stopPropagation ) {

        // 因此它支持W3C的stopPropagation()方法 

        e.stopPropagation();

    } else { 

        // 否则，我们需要使用IE的方式来取消事件冒泡

        window.event.cancelBubble = true;

    }

}

//  功能：阻止事件默认行为
function stopDefault( e ) {
     // 阻止默认浏览器动作(W3C)
     if ( e && e.preventDefault ) {
         e.preventDefault();
     } else {
        // IE中阻止函数器默认动作的方式
        window.event.returnValue = false;
    }
    return false;
}

function timeFormat() {
// 	{$zixun.time|date="Y-m-d H:i:s",###}
}

$(function () {
	var loading = false;
	$("#loadMore").click(function (e) {
		stopDefault(e);
		
		var url = $("#loadMore").attr('href');
		if (loading) {
			return false;
		}
		
		loading = true;
		$.ajax({
			url: url,
			dataType: 'json',
			type: 'GET',
			success: function (result) {
				loading = false;
				if (typeof result.success != 'undefined' && !result.success) {
					var list = result.data.list, html = '';
					
					for (var i in list) {
						if (list.hasOwnProperty(i)) {
							var zixun = list [i];
							
							html += '<li>'
					           +'<a target="_blank" href="{:U(\'Article/detail\')}?id='+zixun.id+'" >'
					           +'<div class="zi_left">'
					           +'<h1>'+zixun.title+'</h1>'
					           +'<p>'+zixun.article_desc+'</p>'
					           +'<span>'+timeFormat(zixun.time)+'</span>'
					           +'</div><div class="img">'
					           +'<img src="__UPLOADS__/Article/'+zixun.img_path+'">'
					           +'</a></div>'
					           +'</li>';
						}
					}
					
					$('ul').append(html);
					if (result.data.hasMore == 0) {
						$('#loadMore').parents('.loadmore').remove();
					} else {
						$("#loadMore").attr('href', result.data.url);
					}
					
					textFormat();
				}
			},
			error: function () {
				loading = false;
			}
		});
	});
});
</script>
</if>
</html>
